#include<iostream>
#include<string>
//类
class Student
{
public:
    //成员函数（方法）
    //缺省构造（无参构造）
    Student() 
    {
        std::cout << "无参构造函数:" << std::endl;
    }
    //带参构造函数
    Student(std::string name,int age)
    {
        std::cout << "带参构造函数:" << std::endl;
        m_age = age;
        m_name = name;
    }
    Student(Student& s) 
    {
        std::cout << "拷贝构造函数:" << std::endl;
        m_name = s.m_name;
        m_age = s.m_age;
    }
    //赋值运算符的重载 调用时机：  s=s1
    void operator=(Student &s)
    {
        std::cout << "赋值运算符的重载" << std::endl;
        m_name = s.m_name;
        m_age = s.m_age;
    }

    //析构函数:无返回值，函数名和类名相同 ~ 无参数
    ~Student()
    {
        std::cout << "析构函数" << std::endl;
    }

    void show();
    void SetAge(int age);

    void SetName(std::string name);

private:
    //成员变量（属性）
    std::string m_name;
    int m_age;

};
void Student::show()
{
    std::cout << "学生姓名：" << m_name << "  学生年龄:" << m_age << std::endl;
}
void Student::SetAge(int age)
{
    m_age = age;
}
void Student::SetName(std::string name)
{
    m_name = name;
}

int main()
{
    
    Student s={"zhangsan",21};
    s.show();
    Student s1;
    s1 = s;
    s1.show();
    return 0;
}